home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / dev / fsystem-1.2 / fio.mod < prev    next >
Encoding:
Text File  |  1980-01-01  |  18.4 KB  |  681 lines

  1. (* (* $VER: fio 1.2 (24-Nov-93) Copyright © by Lars Düning *) *)
  2.  
  3. MODULE fio;
  4.  
  5. (*---------------------------------------------------------------------------
  6. ** File-IO for Amiga-Oberon.
  7. **
  8. ** Copyright © 1991-1993  Lars Düning  -  All rights reserved.
  9. ** Permission granted for non-commercial use.
  10. **---------------------------------------------------------------------------
  11. ** CREDIT
  12. **   The module evolved from the io standard module of Amiga-Oberon 1.17.1
  13. **---------------------------------------------------------------------------
  14. ** Oberon-2: Amiga-Oberon v3.10, F. Siebert / A+L AG
  15. **---------------------------------------------------------------------------
  16. ** [lars] Lars Düning; Am Wendenwehr 25; D-38114-Braunschweig;
  17. **                     Germany; Tel. 49-531-345692
  18. **---------------------------------------------------------------------------
  19. ** 25-Feb-91 [lars]
  20. ** 28-Feb-91 [lars] improved WriteString().
  21. ** 22-Jan-91 [lars] adapted for Oberon v2.00
  22. ** 08-Mar-93 [lars] Stdxxx channels added.
  23. ** 24-Nov-93 [lars] adapted for Oberon v3.10
  24. **---------------------------------------------------------------------------
  25. *)
  26.  
  27. (* $OvflChk- $RangeChk- $StackChk- $NilChk- $ReturnChk- $CaseChk- *)
  28.  
  29. IMPORT
  30.   (* $IF Debug *) Debug, (* $END *)
  31.   d:Dos, e:Exec, wb:Workbench, Icon,
  32.   fs:FSystem,
  33.   ol:OberonLib, s:SYSTEM;
  34.  
  35. (*-------------------------------------------------------------------------*)
  36.  
  37. CONST
  38.  
  39.   StdBufSize * = fs.StdBufSize;  (* default buffer size *)
  40.  
  41.     (* Open() access modes *)
  42.  
  43.   newFile * = fs.newFile;   (* excl. access, deletes existing file *)
  44.   oldFile * = fs.oldFile;   (* shared access, file has to exist *)
  45.   update  * = fs.update;    (* excl. access, file may exist *)
  46.  
  47.     (* Open() operation modes *)
  48.  
  49.   writeOnly * = fs.writeOnly;
  50.   readOnly  * = fs.readOnly;
  51.   readWrite * = fs.readWrite;
  52.  
  53.     (* File.status, in fact error codes *)
  54.  
  55.   ok        * = fs.ok;        (* no error *)
  56.   eof       * = fs.eof;       (* reached end of file *)
  57.   readerr   * = fs.readerr;   (* unspecified read error, ask Dos *)
  58.   writeerr  * = fs.writeerr;  (* unspecified write error, ask Dos *)
  59.   onlyread  * = fs.onlyread;  (* file is read only *)
  60.   onlywrite * = fs.onlywrite; (* file is write only *)
  61.   toofar    * = fs.toofar;    (* seeked beyond the file's ends *)
  62.   outofmem  * = fs.outofmem;  (* ran out of memory *)
  63.   cantopen  * = fs.cantopen;  (* couldn't open file *)
  64.   cantlock  * = fs.cantlock;  (* couldn't lock file *)
  65.  
  66. TYPE
  67.   FilePtr * = fs.FilePtr;
  68.   File    * = fs.File;
  69.  
  70. VAR
  71.   stdin   * : d.FileHandlePtr;  (* starting process's standard input *)
  72.   stdout  * : d.FileHandlePtr;  (* starting process's standard outout *)
  73.   stderr  * : d.FileHandlePtr;  (* starting process's standard error output *)
  74.  
  75. (*-------------------------------------------------------------------------*)
  76.  
  77. TYPE
  78.   String = ARRAY 40 OF CHAR;
  79.  
  80. VAR
  81.   l      : LONGINT;
  82.   ftemp  : ARRAY 256 OF CHAR; (* sufficient long! *)
  83.   helpstr: String;
  84.  
  85.  
  86. (*-------------------------------------------------------------------------*)
  87. PROCEDURE * RFProc; (* $EntryExitCode- *)
  88.  
  89. (* Reader function for Exec.RawDoFmt().
  90. *)
  91.  
  92. BEGIN
  93.   s.INLINE(016C0U,  (* MOVE.B D0,(A3)+ *)
  94.            04E75U); (* RTS             *)
  95. END RFProc;
  96.  
  97. (*-------------------------------------------------------------------------*)
  98. PROCEDURE Length * (str: ARRAY OF CHAR): LONGINT; (* $EntryExitCode- *)
  99.  
  100. (* Determine the length of a string.
  101. **
  102. ** Arguments:
  103. **   str: the string to check.
  104. **
  105. ** Result:
  106. **   The strings length.
  107. **
  108. ** The replication of this function here (it belongs to Strings) shows
  109. ** clearly the need for INLINE PROCEDUREs.
  110. *)
  111.  
  112. BEGIN
  113. s.INLINE(0225FH,                  (*     MOVEA.L     (A7)+,A1       *)
  114.          0201FH,                  (*     MOVE.L      (A7)+,D0       *)
  115.          0205FH,                  (*     MOVEA.L     (A7)+,A0       *)
  116.          05380H,                  (*     SUBQ.L      #1,D0          *)
  117.          02200H,                  (*     MOVE.L      D0,D1          *)
  118.          04A18H,                  (* l:  TST.B       (A0)+          *)
  119.          057C9H,0FFFCH,           (*     DBEQ        D1,l           *)
  120.          06708H,                  (*     BEQ         e              *)
  121.          00481H,00001H,00000H,    (*     SUBI.L      #00010000H,D1  *)
  122.          06AF0H,                  (*     BPL         l              *)
  123.          09081H,                  (* e:  SUB.L       D1,D0          *)
  124.          04ED1H);                 (*     JMP         (A1)           *)
  125. END Length;
  126.  
  127. (*-------------------------------------------------------------------------*)
  128. PROCEDURE write * {"fio.Write"}(VAR out : File; ch: CHAR);
  129. PROCEDURE Write * (VAR out : File; ch: CHAR) : BOOLEAN;
  130.  
  131. (* Write a character into a file.
  132. **
  133. ** Arguments:
  134. **   ch : the character to write.
  135. **   out: the file to write into.
  136. **
  137. ** Result:
  138. **   TRUE on success, else FALSE with out.status denoting the error.
  139. *)
  140.  
  141. BEGIN
  142.   RETURN fs.WriteChar(out,ch);
  143. END Write;
  144.  
  145.  
  146. (*-------------------------------------------------------------------------*)
  147. PROCEDURE writeLn * {"fio.WriteLn"}(VAR out : File);
  148. PROCEDURE WriteLn * (VAR out : File) : BOOLEAN;
  149.  
  150. (* Write a Newline into a file.
  151. **
  152. ** Arguments:
  153. **   out: the file to write into.
  154. **
  155. ** Result:
  156. **   TRUE on success, else FALSE with out.status denoting the error.
  157. *)
  158.  
  159. BEGIN
  160.   RETURN fs.WriteChar(out,'\n');
  161. END WriteLn;
  162.  
  163. (*-------------------------------------------------------------------------*)
  164. (* $CopyArrays- *)
  165. PROCEDURE writeString * {"fio.WriteString"}(VAR out: File; str: ARRAY OF CHAR);
  166. (* $CopyArrays- *)
  167. PROCEDURE WriteString * (VAR out: File; str: ARRAY OF CHAR) : BOOLEAN;
  168.  
  169. (* Write a string into a file.
  170. **
  171. ** Arguments:
  172. **   out: the file to write into.
  173. **   str: the string to write.
  174. **
  175. ** Result:
  176. **   TRUE on success, else FALSE with out.status denoting the error.
  177. **
  178. ** Newlines are not added.
  179. *)
  180.  
  181. VAR
  182.   dataLen, aktLen : LONGINT;
  183.   fOk : BOOLEAN;
  184. BEGIN
  185.   dataLen := Length(str);
  186.   fOk := fs.WriteBlock(out,s.ADR(str),dataLen, aktLen);
  187.   IF dataLen # aktLen THEN
  188.     fOk := FALSE;
  189.     out.status := fs.writeerr;
  190.   END;
  191.   RETURN fOk;
  192. END WriteString;
  193.  
  194. (*-------------------------------------------------------------------------*)
  195. PROCEDURE tab * {"fio.Tab"}(VAR out : File; n: INTEGER);
  196. PROCEDURE Tab * (VAR out : File; n: INTEGER) : BOOLEAN;
  197.  
  198. (* Output spaces into a file.
  199. **
  200. ** Arguments:
  201. **   out : the file to write to.
  202. **   n   : the number of spaces to write.
  203. **
  204. ** Result:
  205. **   TRUE on success, else FALSE with out.status denoting the error.
  206. **
  207. ** The output is linewrapped to 80 chars per line.
  208. *)
  209.  
  210. VAR s: ARRAY 80 OF CHAR;
  211.     i: INTEGER;
  212. BEGIN
  213.   WHILE n>0 DO
  214.     i := 0;
  215.     REPEAT
  216.       s[i] := " ";
  217.       INC(i);
  218.     UNTIL (i=79) OR (i=n);
  219.     DEC(n,i);
  220.     s[i] := 0X;
  221.     IF ~WriteString (out, s) THEN
  222.       RETURN FALSE;
  223.     END;
  224.   END;
  225.   RETURN TRUE;
  226. END Tab;
  227.  
  228. (*-------------------------------------------------------------------------*)
  229. PROCEDURE clear * {"fio.Clear"}(VAR out : File);
  230. PROCEDURE Clear * (VAR out : File) : BOOLEAN;
  231.  
  232. (* Output a formfeed into a file.
  233. **
  234. ** Arguments:
  235. **   out : the file to write to.
  236. **
  237. ** Result:
  238. **   TRUE on success, else FALSE with out.status denoting the error.
  239. *)
  240.  
  241. BEGIN
  242.   RETURN fs.WriteChar(out,'\f');
  243. END Clear;
  244.  
  245. (*-------------------------------------------------------------------------*)
  246. PROCEDURE format * {"fio.Format"}(VAR out : File; VAR str: String; data:LONGINT);
  247. PROCEDURE Format * (VAR out : File; VAR str: String; data:LONGINT) : BOOLEAN;
  248.  
  249. (* Output a single formatted item into a file.
  250. **
  251. ** Arguments:
  252. **   out  : the file to write to.
  253. **   str  : the format string.
  254. **   data : the item to output.
  255. **
  256. ** Result:
  257. **   TRUE on success, else FALSE with file.status denoting the error.
  258. **
  259. ** %% => %
  260. **     links  führ.0   min.max Breite  longdata   dez|hex|string|char
  261. **   %  [-]    [0]      [123 [.123] ]     [l]        (d|x|s|c)
  262. **
  263. **   Char is always WORD, even when specified as 'l'!
  264. **   String adresses are always LONG!
  265. **
  266. ** Do NOT generate more than 255 chars.
  267. *)
  268.  
  269. BEGIN
  270.   e.OldRawDoFmt(str,data,RFProc,s.ADR(ftemp));
  271.   RETURN WriteString(out, ftemp);
  272. END Format;
  273.  
  274. (*-------------------------------------------------------------------------*)
  275. PROCEDURE writeInt * {"fio.WriteInt"}(VAR out: File; x: LONGINT; n: INTEGER);
  276. PROCEDURE WriteInt * (VAR out: File; x: LONGINT; n: INTEGER) : BOOLEAN;
  277.  
  278. (* Output an integer into a file.
  279. **
  280. ** Arguments:
  281. **   out  : the file to write to.
  282. **   x    : the integer to write.
  283. **   n    : the minimal number of characters to write.
  284. **
  285. ** Result:
  286. **   TRUE on success, else FALSE with out.status denoting the error.
  287. **
  288. ** The integer will be leftadjusted.
  289. *)
  290.  
  291. BEGIN
  292.   e.OldRawDoFmt('%%%dld',s.ADR(n),RFProc,s.ADR(helpstr));
  293.   RETURN Format(out,helpstr,s.ADR(x));
  294. END WriteInt;
  295.  
  296.  
  297. (*-------------------------------------------------------------------------*)
  298. PROCEDURE writeHex * {"fio.WriteHex"}(VAR out : File; x: LONGINT; n: INTEGER);
  299. PROCEDURE WriteHex * (VAR out : File; x: LONGINT; n: INTEGER) : BOOLEAN;
  300.  
  301. (* Output a hex integer into a file.
  302. **
  303. ** Arguments:
  304. **   out  : the file to write to.
  305. **   x    : the integer to write.
  306. **   n    : the minimal number of characters to write.
  307. **
  308. ** Result:
  309. **   TRUE on success, else FALSE with out.status denoting the error.
  310. **
  311. ** The integer will be leftadjusted and written in base-16 with leading zeroes.
  312. *)
  313.  
  314. BEGIN
  315.   IF n>=0 THEN (* RawDoFmt makes nonsense for negative numbers of leading zeroes *)
  316.     e.OldRawDoFmt('%%0%dlx',s.ADR(n),RFProc,s.ADR(helpstr));
  317.   ELSE
  318.     n:=-n;
  319.     e.OldRawDoFmt('%%-%dlx',s.ADR(n),RFProc,s.ADR(helpstr));
  320.   END;
  321.   RETURN Format(out,helpstr,s.ADR(x));
  322. END WriteHex;
  323.  
  324. (*-------------------------------------------------------------------------*)
  325. PROCEDURE read * {"fio.Read"}(VAR in : File; VAR ch: CHAR);
  326. PROCEDURE Read * (VAR in : File; VAR ch: CHAR) : BOOLEAN;
  327.  
  328. (* Read a character from a file.
  329. **
  330. ** Arguments:
  331. **   in : the file to read from.
  332. **   ch : variable taking the character to read
  333. **
  334. ** Result:
  335. **   TRUE on success, else FALSE with file.status denoting the error.
  336. **   ch: the character read.
  337. *)
  338.  
  339. BEGIN
  340.   RETURN fs.ReadChar(in,ch);
  341. END Read;
  342.  
  343. (*-------------------------------------------------------------------------*)
  344. PROCEDURE readString * {"fio.ReadString"}(VAR in : File; VAR str: ARRAY OF CHAR);
  345. PROCEDURE ReadString * (VAR in : File; VAR str: ARRAY OF CHAR) : BOOLEAN;
  346.  
  347. (* Read a string from a file.
  348. **
  349. ** Arguments:
  350. **   in  : the file to read from.
  351. **   str : variable taking the string to read
  352. **
  353. ** Result:
  354. **   TRUE on success, else FALSE with file.status denoting the error.
  355. **   str: the string read.
  356. **
  357. ** The function reads until an \0 or \n is encountered (which won't be
  358. ** stored), or the buffer is exhausted. If possible, the string
  359. ** is terminated by \0.
  360. *)
  361.  
  362. BEGIN
  363.   RETURN fs.ReadString (in, str);
  364. END ReadString;
  365.  
  366. (*-------------------------------------------------------------------------*)
  367. PROCEDURE readLong * {"fio.ReadLong"}(VAR in : File; VAR x: LONGINT);
  368. PROCEDURE ReadLong * (VAR in : File; VAR x: LONGINT): BOOLEAN;
  369.  
  370. (* Read a long integer from a file.
  371. **
  372. ** Arguments:
  373. **   in : the file to read from.
  374. **   x  : variable taking the long integer read
  375. **
  376. ** Result:
  377. **   TRUE on success, else FALSE with file.status denoting the error.
  378. **     If FALSE is returned, but in.status is 'ok', then the read characters
  379. **     do not form a legal number.
  380. **   x: the long integer read.
  381. **
  382. ** Linebreaks after a number aren't read.
  383. ** Leading whitespace will be ignored.
  384. *)
  385.  
  386. VAR
  387.   ch: CHAR;
  388.   d: LONGINT;
  389.   neg: BOOLEAN;
  390.   isInt : BOOLEAN;
  391.   fOk : BOOLEAN;
  392. BEGIN
  393.   x := 0; isInt := FALSE;
  394.   neg := FALSE;
  395.  
  396.   (* Skip any preceeding spaces/tabs *)
  397.   REPEAT
  398.     IF ~Read (in, ch) THEN RETURN FALSE; END;
  399.   UNTIL (ch # ' ') AND (ch # '\t');
  400.  
  401.   (* Check for sign *)
  402.   IF (ch="-") OR (ch = "+") THEN
  403.     neg := (ch = "-");
  404.     IF ~Read (in, ch) THEN RETURN FALSE; END;
  405.   END;
  406.  
  407.   (* Read digits *)
  408.   LOOP
  409.     CASE ch OF
  410.       "0".."9": d := ORD(ch)-ORD("0");
  411.     ELSE EXIT
  412.     END;
  413.     IF (MAX(LONGINT)-d) DIV 10 >= x THEN
  414.       x := 10*x+d; isInt := TRUE;
  415.       fOk := Read (in, ch);
  416.       IF ~fOk THEN EXIT; END;
  417.     ELSE
  418.       isInt := FALSE;
  419.       EXIT
  420.     END;
  421.   END;
  422.   IF isInt AND neg THEN x := -x; END;
  423.   IF fOk THEN fOk := fs.Backward (in, 1); END;
  424.   RETURN isInt & fOk;
  425. END ReadLong;
  426.  
  427. (*-------------------------------------------------------------------------*)
  428. PROCEDURE readInt * {"fio.ReadInt"}(VAR in : File; VAR x: INTEGER);
  429. PROCEDURE ReadInt * (VAR in : File; VAR x: INTEGER): BOOLEAN;
  430.  
  431. (* Read an integer from a file.
  432. **
  433. ** Arguments:
  434. **   in : the file to read from.
  435. **   x  : variable taking the integer read
  436. **
  437. ** Result:
  438. **   TRUE on success, else FALSE with file.status denoting the error.
  439. **     If FALSE is returned, but in.status is 'ok', then the read characters
  440. **     do not form a legal number.
  441. **   x: the integer read.
  442. **
  443. ** Linebreaks after a number aren't read.
  444. ** Leading whitespace will be ignored.
  445. *)
  446.  
  447. VAR
  448.   l: LONGINT;
  449. BEGIN
  450.   IF ReadLong(in,l) AND (l>=MIN(INTEGER)) AND (l<=MAX(INTEGER)) THEN
  451.     x := SHORT(l);
  452.     RETURN TRUE;
  453.   END;
  454.   RETURN FALSE;
  455. END ReadInt;
  456.  
  457. (*-------------------------------------------------------------------------*)
  458. PROCEDURE readShort * {"fio.ReadShort"}(VAR in : File; VAR x: SHORTINT);
  459. PROCEDURE ReadShort * (VAR in : File; VAR x: SHORTINT): BOOLEAN;
  460.  
  461. (* Read a short integer from a file.
  462. **
  463. ** Arguments:
  464. **   in : the file to read from.
  465. **   x  : variable taking the short integer read
  466. **
  467. ** Result:
  468. **   TRUE on success, else FALSE with file.status denoting the error.
  469. **     If FALSE is returned, but in.status is 'ok', then the read characters
  470. **     do not form a legal number.
  471. **   x: the short integer read.
  472. **
  473. ** Linebreaks after a number aren't read.
  474. ** Leading whitespace will be ignored.
  475. *)
  476.  
  477. VAR
  478.   l: LONGINT;
  479. BEGIN
  480.   IF ReadLong(in,l) AND (l>=MIN(SHORTINT)) AND (l<=MAX(SHORTINT)) THEN
  481.     x := SHORT(SHORT(l));
  482.     RETURN TRUE;
  483.   END;
  484.   RETURN FALSE;
  485. END ReadShort;
  486.  
  487. (*-------------------------------------------------------------------------*)
  488. PROCEDURE readHex * {"fio.ReadHex"}(VAR in : File; VAR x: LONGINT);
  489. PROCEDURE ReadHex * (VAR in : File; VAR x: LONGINT): BOOLEAN;
  490.  
  491. (* Read a long integer in base-16 notation from a file.
  492. **
  493. ** Arguments:
  494. **   in : the file to read from.
  495. **   x  : variable taking the long integer read
  496. **
  497. ** Result:
  498. **   TRUE on success, else FALSE with file.status denoting the error.
  499. **     If FALSE is returned, but in.status is 'ok', then the read characters
  500. **     do not form a legal number.
  501. **   x: the long integer read.
  502. **
  503. ** Linebreaks after a number aren't read.
  504. ** Leading whitespace will be ignored.
  505. *)
  506.  
  507. VAR
  508.   ch: CHAR;
  509.   d: LONGINT;
  510.   isHex: BOOLEAN;
  511.   fOk : BOOLEAN;
  512. BEGIN
  513.   x := 0; isHex := FALSE;
  514.  
  515.   (* Skip any preceeding spaces/tabs *)
  516.   REPEAT
  517.     IF ~Read (in, ch) THEN RETURN FALSE; END;
  518.   UNTIL (ch # ' ') AND (ch # '\t');
  519.  
  520.   (* Read digits *)
  521.   LOOP
  522.     CASE ch OF
  523.     | '0'..'9': DEC(ch,ORD("0"));
  524.     | 'A'..'F': DEC(ch,ORD("A")-10);
  525.     | 'a'..'f': DEC(ch,ORD("a")-10);
  526.     ELSE EXIT END;
  527.     d := ORD(ch);
  528.     IF (MAX(LONGINT)-d) DIV 16 >= x THEN
  529.       x := 16*x+d; isHex := TRUE;
  530.       fOk := Read (in, ch);
  531.       IF ~fOk THEN EXIT; END;
  532.     ELSE isHex := FALSE; EXIT END;
  533.   END;
  534.  
  535.   IF fOk THEN fOk := fs.Backward (in, 1); END;
  536.   RETURN isHex & fOk;
  537. END ReadHex;
  538.  
  539. (*-------------------------------------------------------------------------*)
  540. (* $CopyArrays- *)
  541. PROCEDURE Use * (VAR    file: File
  542.                 ;       name: ARRAY OF CHAR
  543.                 ;    accMode: INTEGER
  544.                 ;    opMode : INTEGER
  545.                 ;    bufsize: LONGINT
  546.                 ): BOOLEAN;
  547.  
  548.  
  549. (* Open a file according to access and operation mode.
  550. **
  551. ** Arguments:
  552. **   file: the empty(!) File structure to fill in.
  553. **   name: the name of the file to open (will be copied into file).
  554. **   accMode: the access mode to use.
  555. **   opMode : the operation mode to use.
  556. **   bufSize: size of the buffer to allocate, must be at least 1.
  557. **
  558. ** Result:
  559. **   TRUE on success, else FALSE with file.status denoting the error.
  560. **
  561. ** A bufsize of 1 will result in unbuffered io.
  562. *)
  563.  
  564. BEGIN
  565.   RETURN fs.Use (file, name, accMode, opMode, bufsize);
  566. END Use;
  567.  
  568. (*-------------------------------------------------------------------------*)
  569. (* $CopyArrays- *)
  570. PROCEDURE open * (VAR    file: File
  571.                  ;       name: ARRAY OF CHAR
  572.                  ;    accMode: INTEGER
  573.                  ): BOOLEAN;
  574.  
  575. (* Open a file for read/write with a default sized buffer.
  576. **
  577. ** Arguments:
  578. **   file: the empty(!) File structure to fill in.
  579. **   name: the name of the file to open (will be copied into file).
  580. **   accMode: the access mode to use.
  581. **
  582. ** Result:
  583. **   TRUE on success, else FALSE with file.status denoting the error.
  584. **
  585. ** The allocated buffer will be of StdBufSize.
  586. ** The file will be opened for reading and writing.
  587. *)
  588.  
  589. BEGIN
  590.   RETURN Use (file, name, accMode, readWrite, StdBufSize);
  591. END open;
  592.  
  593. (*-------------------------------------------------------------------------*)
  594. PROCEDURE close * {"fio.Close"} (VAR file: File);
  595. PROCEDURE Close * (VAR file: File): BOOLEAN;
  596.  
  597. (* Close the file.
  598. **
  599. ** Arguments:
  600. **   file: the file to close.
  601. **
  602. ** Result:
  603. **   TRUE on success, else FALSE with file.status denoting the error.
  604. **
  605. ** Before closing, all changed data is written out using FlushBuf().
  606. *)
  607.  
  608. BEGIN
  609.   RETURN fs.Close (file);
  610. END Close;
  611.  
  612. (*-------------------------------------------------------------------------*)
  613. PROCEDURE StdIn * () : d.FileHandlePtr;
  614.  
  615. (* The current processes standard input.
  616. **
  617. ** Result:
  618. **   The FileHandle of standard input or NIL;
  619. **
  620. ** Don't call this function for simple tasks!
  621. *)
  622.  
  623. VAR
  624.   me : d.ProcessPtr;
  625. BEGIN
  626.   me := e.FindTask(NIL);
  627.   RETURN me.cis;
  628. END StdIn;
  629.  
  630. (*-------------------------------------------------------------------------*)
  631. PROCEDURE StdOut * () : d.FileHandlePtr;
  632.  
  633. (* The current processes standard output.
  634. **
  635. ** Result:
  636. **   The FileHandle of standard output or NIL;
  637. **
  638. ** Don't call this function for simple tasks!
  639. *)
  640.  
  641.   VAR
  642.     me : d.ProcessPtr;
  643. BEGIN
  644.   me := e.FindTask(NIL);
  645.   RETURN me.cos;
  646. END StdOut;
  647.  
  648.  
  649. (*-------------------------------------------------------------------------*)
  650. PROCEDURE StdErr * () : d.FileHandlePtr;
  651.  
  652. (* The current processes standard error output.
  653. **
  654. ** Result:
  655. **   The FileHandle of standard error output or NIL;
  656. **
  657. ** Don't call this function for simple tasks!
  658. ** For OS < 2.0, stderr is stdout.
  659. *)
  660.  
  661.   VAR
  662.     me : d.ProcessPtr;
  663.     stderr : d.FileHandlePtr;
  664. BEGIN
  665.   me := e.FindTask(NIL);
  666.   IF e.exec.libNode.version < 37 THEN
  667.     RETURN me.cos;
  668.   END;
  669.   RETURN me.ces;
  670. END StdErr;
  671.  
  672. (*=========================================================================*)
  673.  
  674. BEGIN
  675.   stdin := StdIn();
  676.   stdout := StdOut();
  677.   stderr := StdErr();
  678. END fio.
  679.  
  680. (***************************************************************************)
  681.